home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / VIEWS.ZIP;1 / CVDZIP.EXE / CVDIALOG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-20  |  4.1 KB  |  173 lines

  1. /*
  2.     cvdialog.cpp
  3.  
  4.     Example dialog box
  5.  
  6.     C++/Views 2.0 Demo
  7.     Copyright (c) 1992, by Liant Software Corp.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12. */
  13.  
  14. #include "cvdialog.h"
  15. #include "editline.h"
  16. #include "pushbttn.h"
  17. #include "combobox.h"
  18. #include "exclgrp.h"
  19. #include "radibttn.h"
  20. #include "textbox.h"
  21. #include "listbox.h"
  22. #include "cvcolor.h"
  23. #include "cvdemovw.h"
  24. #include "messengr.h"
  25. #include "cvhow.h"
  26.  
  27. defineClass(DialogView, VDialog)
  28.  
  29. char *radioBttns[] = { "Illuminati", "Jesuits", "Masons", "Templars", 0 };
  30.  
  31. DialogView::DialogView()
  32. {
  33.     ;
  34. }
  35.  
  36. DialogView::DialogView(VWindow *parent)
  37.     : VDialog(30, 10, 150, 180, parent)
  38. {
  39.     setTitle("C++/Views Sample Dialog");
  40.  
  41.     /* add an edit line */
  42.     pEdit = new VEditLine(VFrame(160, 18, 110, 25), this, StyleBorder);
  43.     new VTextBox(VFrame(40, 20, 100, 25), this, StyleRight, "Edit Line");
  44.  
  45.     /* add a combo box */
  46.     VComboBox *pCombo;
  47.     pCombo = new VComboBox(VFrame(160, 58, 120, 140), this, StyleComboDrop);
  48.     new VTextBox(VFrame(40, 60, 100, 25), this, StyleRight, "Combo Box");
  49.  
  50.     pCombo->appendString("Ball and Chain");
  51.     pCombo->appendString("Block and Tackle");
  52.     pCombo->appendString("Chutes and Ladders");
  53.     pCombo->appendString("Gin and Tonic");
  54.     pCombo->appendString("Martin and Lewis");
  55.     pCombo->appendString("Mortar and Pestle");
  56.     pCombo->appendString("Ren and Stimpy");
  57.     pCombo->appendString("Pastrami and Rye");
  58.     pCombo->appendString("Sturm und Drang");
  59.  
  60.     /* add a custom control */
  61.     new ColorControl(VFrame(160, 90, 120, 50), this, StyleBorder);
  62.     new VTextBox(VFrame(10, 90, 130, 25), this, StyleRight, "Custom Control");
  63.  
  64.     /* create a group of exclusive radio buttons */
  65.     VExclusiveGroup *group;
  66.  
  67.     group = new VExclusiveGroup(VFrame(20, 150, 120, 123), this,
  68.             "Exclusive Group", VRadioButtonCls);
  69.     group->addButtons(radioBttns, .1F, .2F, .8F, .15F, 0.0F, .05F);
  70.  
  71.     /* create a list box */
  72.     new VTextBox(VFrame(160, 156, 120, 20), this, StyleLeft, "List Box");
  73.     listBox = new VListBox(VFrame(160, 178, 120, 97), this, StyleBorder | StyleTitle);
  74.     listBox->uponClick(this, methodOf(DialogView, listClick),
  75.                              methodOf(DialogView, listDblClick));
  76.  
  77.     listBox->appendString("Account");
  78.     listBox->appendString("Atlas");
  79.     listBox->appendString("Catalog");
  80.     listBox->appendString("Compendium");
  81.     listBox->appendString("Directory");
  82.     listBox->appendString("Enumeration");
  83.     listBox->appendString("Index");
  84.     listBox->appendString("Litany");
  85.     listBox->appendString("Register");
  86.     listBox->appendString("Roster");
  87.     listBox->appendString("Tally");
  88.  
  89.     /* create pushbuttons */
  90.     VPushButton *okButton;
  91.     okButton = new VPushButton(VFrame(20, 300, 50, 30), this, StyleDefault, "Ok");
  92.     okButton->uponClick(this, methodOf(DialogView, okBtn));
  93.  
  94.     VPushButton *cancelButton;
  95.     cancelButton = new VPushButton(VFrame(230, 300, 50, 30), this, StyleDefault, "Cancel");
  96.     cancelButton->uponClick(this, methodOf(DialogView, cancelBtn));
  97.  
  98.     VPushButton *aboutButton;
  99.     aboutButton = new VPushButton(VFrame(125, 300, 50, 30), this, StyleDefault, "About");
  100.     aboutButton->uponClick(this, methodOf(DialogView, aboutBtn));
  101. }
  102.  
  103. DialogView::~DialogView()
  104. {
  105.     ;
  106. }
  107.  
  108. boolean DialogView::free()
  109. {
  110.     delete this;
  111.     return(TRUE);
  112. }
  113.  
  114. boolean DialogView::okBtn(VButton *b)
  115. /*
  116.     "Ok" button pressed
  117. */
  118. {
  119.     endModal();
  120.     return(TRUE);
  121. }
  122.  
  123. boolean DialogView::cancelBtn(VButton *b)
  124. /*
  125.     "Cancel" button pressed
  126. */
  127. {
  128.     endModal();
  129.     return(TRUE);
  130. }
  131.  
  132. boolean DialogView::aboutBtn(VButton *b)
  133. /*
  134.     "About" button pressed
  135. */
  136. {
  137.     /* Display a "How-does-it-work" dialog */
  138.     HowView    how(this, "Dialog:About", "cvdialog.cpp");
  139.  
  140.     /* make the about how visible */
  141.     how.show();
  142.  
  143.     /* activate the dialog (as a modal dialog) */
  144.     how.modal();
  145.  
  146.     return(TRUE);
  147. }
  148.  
  149. boolean DialogView::listClick(int index)
  150. /*
  151.     Mouse clicked on the list box
  152. */
  153. {
  154.     return(TRUE);
  155. }
  156.  
  157. boolean DialogView::listDblClick(int index)
  158. /*
  159.     Mouse double-clicked on the list box
  160. */
  161. {
  162.     /* copy the current choice into the editline */
  163.     VString *temp;
  164.     temp = listBox->selectedString();
  165.  
  166.     pEdit->putText(temp->gets());
  167.  
  168.     delete temp;
  169.  
  170.     return(TRUE);
  171. }
  172.  
  173.